﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BeeManagementSystem
{
    class Worker : Bee
    {
        public Worker(string[] jobsICanDo, int weight) : base(weight)
        {
            this.jobsICanDo = jobsICanDo;
        }

        public override int ShiftsLeft
        {
            get
            {
                return shiftsToWork - shiftsWorked;
            }
        }

        public string currentJob = "";
        public string CurrentJob 
        {
            get
            {
                return currentJob; //return the workers current job
            }
        }

        private string[] jobsICanDo;
        private int shiftsToWork;
        private int shiftsWorked;

        public bool DoThisJob(string job, int numberOfShifts)
        {
            if (!String.IsNullOrEmpty(currentJob))
                return false;
            for (int i = 0; i < jobsICanDo.Length; i++) //if not doing a job, and knows how to do the job...
                if (jobsICanDo[i] == job)
                {
                    currentJob = job; //accept the assignment and...
                    this.shiftsToWork = numberOfShifts;
                    shiftsWorked = 0;
                    return true; //return true...
                }
            return false; //return false otherwise.
        }

        public bool WorkOneShift()
        {
            if (String.IsNullOrEmpty(currentJob))
                return false;
            shiftsWorked++;//worker works a shift...Tracks how many shifts are left...
            if (shiftsWorked > shiftsToWork) //If job == done...
            {
                shiftsWorked = 0;
                shiftsToWork = 0;
                currentJob = ""; //current job = ""
                return true;
            }
            else
                return false;
        }
    }
}
